#include "subwindowsetvolumefunctor.h"
#include "mainwindow.h"
#include "localvideoplayer.h"
#include "realtimevideoplayer.h"

SubWindowSetVolumeFunctor::SubWindowSetVolumeFunctor(int windowNo, float volume):
		m_WindowNo(windowNo)
		,m_Volume(volume)
{
}

void SubWindowSetVolumeFunctor::operator ()()
{
	qDebug()<<"In set volume functor";
	MainWindow* mainWindow = MainWindow::instance();
	Player* player = mainWindow->getPlayer(m_WindowNo);

	LocalVideoPlayer* localVideoPlayer = dynamic_cast<LocalVideoPlayer*>(player);
	if(localVideoPlayer != NULL)
	{
//		localVideoPlayer->setvo
		QMetaObject::invokeMethod(
				localVideoPlayer
				,"setVolume"
				,Q_ARG(float, m_Volume));
	}

	RealtimeVideoPlayer* realtimeVideoPlayer = dynamic_cast<RealtimeVideoPlayer*>(player);
	if(realtimeVideoPlayer != NULL)
	{
		qDebug()<<"Before invoke realtime video player set volume";
		QMetaObject::invokeMethod(
			realtimeVideoPlayer
			,"setVolume"
			,Q_ARG(float, m_Volume));

	}
}
